package offer;

public class Solution42 {
    public int maxSubArray(int[] nums) {
        int res = Integer.MIN_VALUE, sum = 0;
        for (int num : nums) {
            sum += num;
            res = Math.max(res, sum);
            sum = Math.max(sum, 0);
        }
        return res;
    }
}
